package com.generator.util;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.system.SystemUtil;
import org.mybatis.generator.api.dom.java.JavaElement;

import java.util.Date;

/**
 * @author fengz
 * @version v1
 * @className Comment
 * @description TODO
 * @site glp.hcdlearning.com
 * @company 合得软件（上海）有限公司
 * @create 2019-07-16 14:36
 */
public class CommentUtil {
    public static void addModelClassComment(JavaElement javaElement, String className ,String description){

        String currentDateStr = DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN);

        StringBuilder sb = new StringBuilder();
        javaElement.addJavaDocLine("/**");
        sb.append(StrUtil.format(" * @author {}\n", SystemUtil.getUserInfo().getName()));
        sb.append(StrUtil.format(" * @version v1\n"));
        sb.append(StrUtil.format(" * @className {}\n",className));
        sb.append(StrUtil.format(" * @description {}\n",description));
        sb.append(StrUtil.format(" * @site glp.hcdlearning.com\n"));
        sb.append(StrUtil.format(" * @company 合得软件（上海）有限公司\n"));
        sb.append(StrUtil.format(" * @create {}",currentDateStr));
        javaElement.addJavaDocLine(sb.toString());
        javaElement.addJavaDocLine(" */");
    }
}
